//
//  BaseTableViewController.m
//  OC-LBWeibo
//
//  Created by 李博 on 15/6/24.
//  Copyright © 2015年 libo. All rights reserved.
//

#import "BaseTableViewController.h"
#import "VisitorLoginView.h"
#import "OAuthViewController.h"
#import "UserAccount.h"

@interface BaseTableViewController ()<VisitorLoginViewDelegate>



@end

@implementation BaseTableViewController

bool userLogon = NO;

- (void)loadView
{
    UserAccount *user = [UserAccount sharedUserAccount];
    if (user != nil) {
        userLogon = YES;
    }
    NSLog(@"%d",userLogon);
    userLogon ? [super loadView] : [self setupVisitorView];
}

- (void)setupVisitorView
{
    self.visitorView.delegate = self;
    self.view = self.visitorView;
    

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(visitorRegisterButtonClicked)];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"登录" style:UIBarButtonItemStylePlain target:self action:@selector(visitorLoginButtonClicked)];
    
    
}

- (VisitorLoginView *)visitorView
{
    if (_visitorView  == nil) {
        _visitorView = [[VisitorLoginView alloc]init];
    }
    return _visitorView;
}

- (void)visitorRegisterButtonClicked
{
    NSLog(@"注册。。。");
}
- (void)visitorLoginButtonClicked
{
    NSLog(@"登录。。。");
    OAuthViewController *vc = [[OAuthViewController alloc]init];
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
    
    [self presentViewController:nav animated:YES completion:nil];
    
    
}


@end
